﻿using System;
using System.Collections.Generic;
using System.Text;

namespace unitlib
{
    /// <summary>
    /// 牛每毫米
    /// </summary>
    public readonly struct Unit_N_mm : IUnit
    {
        public double Value { get; }
        public string Unit => "N/mm";
        public string LatexUnit => "\\mathrm{N/mm}";
        public Unit_N_mm(double value) { Value = value; }
        public Unit_N_mm Round(int digits) => new Unit_N_mm(Math.Round(Value, digits));
        //数值与字符串转换
        public override string ToString() => Value.ToString();
        public static explicit operator Unit_N_mm(double value) => new Unit_N_mm(value);
        public static explicit operator double(Unit_N_mm value) => value.Value;
        public static implicit operator Unit_N_mm(string value) => new Unit_N_mm(value.Parse());
        public static implicit operator Unit_N_mm(Unit_kN_m value) => new Unit_N_mm(value.Value);
        //比较运算
        public static bool operator ==(Unit_N_mm left, Unit_N_mm right) => left.Equals(right);
        public static bool operator !=(Unit_N_mm left, Unit_N_mm right) => !left.Equals(right);
        public override bool Equals(object obj) => obj is Unit_N_mm other && other.Value == Value;
        public override int GetHashCode()
        {
            unchecked
            {
                return GetType().GetHashCode() * 31 + Value.GetHashCode();
            }
        }
        //常规运算
        public static Unit_N_mm operator +(Unit_N_mm left, Unit_N_mm right) => new Unit_N_mm(left.Value + right.Value);
        public static Unit_N_mm operator -(Unit_N_mm left, Unit_N_mm right) => new Unit_N_mm(left.Value - right.Value);
        public static Unit_N_mm operator *(Unit_N_mm left, UnitValue right) => new Unit_N_mm(left.Value * right.Value);
        public static Unit_N_mm operator *(UnitValue left, Unit_N_mm right) => new Unit_N_mm(left.Value * right.Value);
        public static Unit_N_mm operator /(Unit_N_mm left, UnitValue right) => new Unit_N_mm(left.Value / right.Value);
        public static UnitValue operator /(Unit_N_mm left, Unit_N_mm right) => new UnitValue(left.Value / right.Value);
        //新增运算  
        public static Unit_N operator *(Unit_N_mm left, Unit_mm right) => new Unit_N(left.Value*right.Value); 
    }
}
